Object.defineProperty(exports, "__esModule", {
  value: true
});
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_Pool = function (e) {
  function _ctor() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.inPool = null;
    t.poolIdx = 0;
    t.pool = [];
    t.poolDirc = {};
    t.size = 100;
    t.actives = {};
    t.sleeps = {};
    return t;
  }
  __extends(_ctor, e);
  _ctor.prototype.createPool = function (e) {
    this.size = e;
  };
  _ctor.prototype.getNewPoolItem = function () {
    for (var e in this.sleeps) {
      delete this.sleeps[e];
      this.actives[e] = 1;
      var t = parseInt(e) - 1e5 * this.poolIdx;
      this.pool[t].active = true;
      return this.pool[t];
    }
    var o = cc.instantiate(this.inPool);
    o.setParent(this.node);
    this.pool.push(o);
    o.inPoolIdx = this.pool.length - 1 + 1e5 * this.poolIdx;
    o.name = "pool" + o.inPoolIdx;
    this.actives[o.inPoolIdx] = 1;
    this.poolDirc[o.inPoolIdx] = o;
    return o;
  };
  _ctor.prototype.destroyPoolItem = function (e) {
    this.pool[e.inPoolIdx - 1e5 * this.poolIdx].active = false;
    delete this.actives[e.inPoolIdx];
    this.sleeps[e.inPoolIdx] = 1;
  };
  _ctor.prototype.destroyAllPoolItem = function () {
    for (var e = 0; e < this.node.children.length; e++) {
      this.node.children[e].active && this.destroyPoolItem(this.node.children[e]);
    }
  };
  _ctor.prototype.getAllActiveItem = function () {
    var e = [];
    for (var t in this.actives) {
      var o = parseInt(t) - 1e5 * this.poolIdx;
      e.push(this.pool[o]);
    }
    return e;
  };
  _ctor.prototype.start = function () {};
  __decorate([ccp_property(cc.Prefab)], _ctor.prototype, "inPool", undefined);
  __decorate([ccp_property(cc.Integer)], _ctor.prototype, "poolIdx", undefined);
  __decorate([ccp_property(cc.Integer)], _ctor.prototype, "size", undefined);
  return __decorate([ccp_ccclass], _ctor);
}(cc.Component);
exports.default = def_Pool;